//
//  GameLevelTipView.m
//  linkingGame
//
//  Created by zw wu on 15/4/11.
//  Copyright (c) 2015年 com.jinWu. All rights reserved.
//

#import "GameLevelTipView.h"

@interface GameLevelTipView ()

@property (nonatomic,retain) UILabel *modeLabel;
@property (nonatomic,retain) UILabel *starLabel;

@end

@implementation GameLevelTipView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [backBtn setTitle:NSLocalizedString(@"back",nil) forState:UIControlStateNormal];
        [self addSubview:backBtn];
        self.backBtn = backBtn;
        
        backBtn.backgroundColor = [UIColor grayColor];
        
        UILabel *modeLabel = [[UILabel alloc]init];
        modeLabel.textAlignment = NSTextAlignmentCenter;
        modeLabel.textColor = [UIColor blackColor];
        [self addSubview:modeLabel];
        self.modeLabel = modeLabel;
        
        modeLabel.backgroundColor = [UIColor whiteColor];
        
        UILabel *starLabel = [[UILabel alloc]init];
        starLabel.textAlignment = NSTextAlignmentCenter;
        starLabel.textColor = [UIColor blackColor];
        [self addSubview:starLabel];
        self.starLabel = starLabel;
        
        starLabel.backgroundColor = [UIColor whiteColor];
    }
    
    return self;
}

- (void)dealloc
{
    self.backBtn = nil;
    self.modeLabel = nil;
    self.starLabel = nil;
    
    [super dealloc];
}

- (void)refreshUI
{
    CGRect backBtnRect,modeLabelRect,starLabelRect;
    if (isPhone())
    {
        self.modeLabel.font = [UIFont boldSystemFontOfSize:24];
        self.starLabel.font = [UIFont boldSystemFontOfSize:18];
        
        backBtnRect = CGRectMake(22, 22, 44, 44);
        modeLabelRect = CGRectMake(88, 10, self.frame.size.width - 110, 40);
        starLabelRect = CGRectMake(88, 50, self.frame.size.width - 110, 30);
    }
    else
    {
        self.modeLabel.font = [UIFont boldSystemFontOfSize:30];
        self.starLabel.font = [UIFont boldSystemFontOfSize:24];
        
        if (isLandscape())
        {
            backBtnRect = CGRectMake(30, 30, 60, 60);
            modeLabelRect = CGRectMake(120, 10, self.frame.size.width - 150, 50);
            starLabelRect = CGRectMake(120, 70, self.frame.size.width - 150, 40);
        }
        else
        {
            backBtnRect = CGRectMake(45, 45, 90, 90);
            modeLabelRect = CGRectMake(180, 40, self.frame.size.width - 225, 50);
            starLabelRect = CGRectMake(180, 100, self.frame.size.width - 225, 40);
        }
    }
    
    self.backBtn.frame = backBtnRect;
    self.modeLabel.frame = modeLabelRect;
    self.starLabel.frame = starLabelRect;
}

- (void)resetGameMode:(KGameMdoe)mode
{
    if (mode == KClassicMode)
    {
        self.modeLabel.text = NSLocalizedString(@"classic_mode",nil);
    }
    else if(mode == KChallengeMode)
    {
        self.modeLabel.text = NSLocalizedString(@"challenge_mode",nil);
    }
}

- (void)resetGameStars:(int)stars withAll:(int)allStars
{
    self.starLabel.text = NSLocalizedString(@"star_tip",nil);
}

@end
